<?php
/**
 *	@name		商品拍卖
 *	@author		Jeffery
 *	@qq			1017756891
 *	@email		1017756891@qq.com
 *	@website	http://www.iweitao.net
**/

if(!defined('IN_DISCUZ')) { //安全判断
	exit('Access Denied');
}
//初始化部分数据
$DISCUZ_PAIPAI_VERSION = "7.0"; //定义当前插件版本

$credit = $_G['cache']['plugin']['iweitao_paipai']['credit'];
$groups = $_G['cache']['plugin']['iweitao_paipai']['groups'];
$types = $_G['cache']['plugin']['iweitao_paipai']['type'];
$count = $_G['cache']['plugin']['iweitao_paipai']['count'];
$mades = $_G['cache']['plugin']['iweitao_paipai']['made'];
$admingroup = $_G['cache']['plugin']['iweitao_paipai']['admingroup'];
$delay_time = $_G['cache']['plugin']['iweitao_paipai']['delay_time'];
$delay_time = $delay_time*60; //转换单位秒
$delay = $_G['cache']['plugin']['iweitao_paipai']['delay'];
$delay = $delay*60; //转换单位秒
$checkv = $_G['cache']['plugin']['iweitao_paipai']['checkv'];
$checkvurl = $_G['cache']['plugin']['iweitao_paipai']['checkvurl'];
$checkvkey = $_G['cache']['plugin']['iweitao_paipai']['checkvkey'];
$types = loadarray($types);
$mades = loadarray($mades);
$groups = unserialize($groups);

function notifity($uid,$msg) { //发送消息通知
	global $_G;
	notification_add($uid ,'post', $msg ,array(),$system = 0);
}

function authenticate_paipai() {
	global $checkv;
	global $checkvurl;
	global $checkvkey;
	global $_G;
	$checkvkeymd5 = md5($checkvkey);
	$contents = file_get_contents($checkvurl."?id=authenticate:user&key=".$checkvkey."&md5=".$checkvkeymd5."&uid=".$_G['uid']."&checktype=1");
	$contents = serialize($contents);
	if(!$contents) {
		showmessage("请先进行V认证在发布");
	} else {
		return true;
	}
}
function checkcredit($price) {
	global $_G;
	global $lang;
	global $credit;
	$query = DB::query("SELECT * FROM `".DB::table("common_member_count")."` WHERE `uid` = '".$_G['uid']."'"); //获取当前用户积分
	while($user_count = mysql_fetch_array($query)) {
		$extcredits = $user_count['extcredits'.$credit];
	}
	if($price >= $extcredits) {
		return false;
	} else {
		return true;
	}
}


class safe_weitao_plugin_iweitao_paipai {
	public function _get($parameter,$number = 0) {
		$parameter = $_GET[$parameter];
		if($number == 1) {
			$parameter = $this->number($parameter);
		} else {
			$parameter = $this->grapheme($parameter);
		}
		return $parameter;
	}
	
	public function _post($parameter,$number = 0 ) {
		$parameter = $_POST[$parameter];
		if($number == 1) {
			$parameter = $this->number($parameter);
		} else {
			$parameter = $this->grapheme($parameter);
		}
		return $parameter;
	}
	
	public function number($number) {
		$number = intval($number);
		return $number;
	}
	
	public function grapheme($parameter) {
		$parameter = addslashes($parameter);
		return $parameter;
	}
	
	public function ungrapheme($parameter) {
		$parameter = stripslashes($parameter);
		return $parameter;
	}
}
$core = new safe_weitao_plugin_iweitao_paipai;

function loadarray($array){
	$return = array();
	$array = explode("\n",str_replace("\r","",$array));
	foreach ($array as $v){
		$t = explode("=",$v);
		$t[0] = trim($t[0]);
		$return[$t[0]] = $t[1];
	}
	return $return;
}
?>